package com.ruoyi.project;

import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import com.ruoyi.common.utils.Md5Utils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.project.pay.Util;
import com.ruoyi.project.pay.qixing.AESUtil;
import com.ruoyi.project.pay.qixing.CryptoUtil;
import com.ruoyi.project.pay.qixing.StringUtil;
import com.ruoyi.project.pay.vnet.RQPayUtils;
import com.ruoyi.project.pay.vnet.SHA256WithRSAUtils;
import com.ruoyi.project.pay.vnet.SSLView;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;

import javax.net.ssl.HttpsURLConnection;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;

public class TestMd5 {
    /**
     * 获取MD5加密后的字符串
     *
     * @param str 明文
     * @return 加密后的字符串
     * @throws Exception
     */
    public static String getMD5(String str) throws Exception {
        /** 创建MD5加密对象 */
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        /** 进行加密 */
        md5.update(str.getBytes());
        /** 获取加密后的字节数组 */
        byte[] md5Bytes = md5.digest();
        String res = "";
        for (int i = 0; i < md5Bytes.length; i++) {
            int temp = md5Bytes[i] & 0xFF;
            if (temp <= 0XF) { // 转化成十六进制不够两位，前面加零
                res += "0";
            }
            res += Integer.toHexString(temp);
        }
        return res;
    }

    public static String getSHA256(String str) {
        MessageDigest messageDigest;
        String encodestr = "";
        try {
            messageDigest = MessageDigest.getInstance("SHA-256");
            messageDigest.update(str.getBytes("UTF-8"));
            encodestr = byte2Hex(messageDigest.digest());
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return encodestr;
    }

    private static String byte2Hex(byte[] bytes) {
        StringBuffer stringBuffer = new StringBuffer();
        String temp = null;
        for (int i = 0; i < bytes.length; i++) {
            temp = Integer.toHexString(bytes[i] & 0xFF);
            if (temp.length() == 1) {
                //1得到一位的进行补0操作
                stringBuffer.append("0");
            }
            stringBuffer.append(temp);
        }
        return stringBuffer.toString();
    }


    public static void main(String args[]) {
        Date date = new Date();
        System.out.println(date.getHours());
//        StringBuilder stringBuilder = new StringBuilder();
//        stringBuilder.append("businessId=14");
//        stringBuilder.append("&payType=04");
//        stringBuilder.append("&childOrderno=2072185454589");
//        stringBuilder.append("&amount=11");
//        stringBuilder.append("&time=20190519155706");
//        stringBuilder.append("&aafajjks@#$%&*ksfkskfkskfkksff");
//        String sign = "";
//        try {
//            sign =getMD5(stringBuilder.toString());
//            System.out.println(stringBuilder.toString());
//            System.out.println(Md5Utils.hash(stringBuilder.toString()));
//            System.out.println(Md5Utils.androidMD5(stringBuilder.toString()));
//            System.out.println("sign:"+sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
////        String url = "http://47.110.231.165:8088/pay/order";
//        String url = "http://127.0.0.1/pay/order";
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("businessId", "14");
//        jsonObject.put("payType", "04");
//        jsonObject.put("childOrderno", "2072185454589");
//        jsonObject.put("amount", "11");
//        jsonObject.put("time", "20190519155706");
////        jsonObject.put("sign", sign);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//        HttpEntity<String> entity = new HttpEntity<String>(jsonObject.toJSONString(),headers);
//        String body = restTemplate.exchange(url, HttpMethod.POST, entity,String.class).getBody();
//        JSONObject jsonObject1 = JSONObject.parseObject(body);
//        System.out.println(jsonObject1.toJSONString());


//        String url = "http://47.110.231.165:8089/pay/order/patch";
//        String url = "http://47.111.144.101/pay/order/patch";
//        StringBuilder stringBuilder = new StringBuilder();
//        // 上游订单编号
//        stringBuilder.append("orderId=20190702222117201251");
//        stringBuilder.append("&payAmount=10.32");
//        stringBuilder.append("&time=20190519155706");
//        stringBuilder.append("&aafajjks@#$%&*ksfkskfkskfkksff");
//        String sign = "";
//        try {
//            System.out.println(stringBuilder.toString());
//            sign = Md5Utils.androidMD5(stringBuilder.toString());
//            System.out.println("sign:" + sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("orderId", "20190702222117201251");
//        jsonObject.put("payAmount", "10.32");
//        jsonObject.put("time", "20190519155706");
//        jsonObject.put("sign", sign);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//        HttpEntity<String> entity = new HttpEntity<String>(jsonObject.toJSONString(), headers);
//        try {
//            JSONObject body = restTemplate.exchange(url, HttpMethod.POST, entity, JSONObject.class).getBody();
//            System.out.println(body.toJSONString());
//        }catch (Exception e){
//            System.out.println("aaaa"+e.getMessage());
//        }

//        String base64String = "http://gapilan.cn/pay/third/d6e4cd197ed411e9867600163e10c068";
//        String ss = new sun.misc.BASE64Encoder().encode(base64String.getBytes());
//        ss = ss.replace("\r\n","");
//        System.out.println(ss);


//        RestTemplate restTemplate = new RestTemplate();
//        String url = "https://urlc.cn/api/add?longurl=http://47.110.231.165";
//        String responseMessage = restTemplate.getForObject(url,String.class);
//        System.out.println(responseMessage);

//        try {
//            RestTemplate restTemplate = new RestTemplate();
//            String url = "http://h5ip.cn/Index/addAddress";         // http://192.168.43.11/pay/alipay?orderId=62d6ebe7862311e99d3f28d244015939
//            String bodyValTemplate = "source=" + URLEncoder.encode("http://118.31.121.214/pay/alipay?orderId=dfsgsfdgsdgsdf", "utf-8") + "&https=1";
//            System.out.println(bodyValTemplate);
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            HttpEntity entity = new HttpEntity(bodyValTemplate, headers);
//            String body =  restTemplate.exchange(url, HttpMethod.POST, entity, String.class).getBody();
//            System.out.println(body);
//            // {"code":0,"msg":"","source":"http:\/\/118.31.121.214\/","short_url":"http:\/\/h5ip.cn\/GgSn"}
//            JSONObject result = JSONObject.parseObject(body);
//            if(result.getInteger("code") == 0){
//               String s=  result.getString("short_url").replace("\\/","/");
//                System.out.println(s);
//            }
//        }catch (Exception e){
//            System.out.println(e);
//        }


//        try {
//            RestTemplate restTemplate = new RestTemplate();
//            String url = "http://qqdwz.com/dwz.php";
//            String bodyValTemplate = "longurl="+ URLEncoder.encode("http://118.31.121.214", "utf-8");//http://118.31.121.214:8088/pay/alipay?orderId=26dbf98c84f111e9b17500163e0c8a6a";
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            headers.add(HttpHeaders.ACCEPT_CHARSET, StandardCharsets.UTF_8.name());
//            headers.set(HttpHeaders.ACCEPT,"application/json; charset=utf-8");
//            HttpEntity entity = new HttpEntity(bodyValTemplate, headers);
//            String body = restTemplate.exchange(url, HttpMethod.POST, entity, String.class).getBody();
//            // {"code":0,"msg":"","source":"http:\/\/118.31.121.214\/","short_url":"http:\/\/h5ip.cn\/GgSn"}
//            JSONObject result = JSONObject.parseObject(body);
//            if (result.getInteger("code") == 1) {
//                String s= result.getString("ae_url").replace("\\/", "/").replace("https","http");
//                System.out.println(s);
//            }
//        } catch (Exception e) {
//           e.printStackTrace();
//        }


//        try{
//            RestTemplate restTemplate = new RestTemplate();
//            String url = "https://api.uomg.com/api/long2dwz?dwzapi=urlcn&url="+URLEncoder.encode("http://118.31.121.214/pay/alipay?orderId=dfsgsfdgsdgsdf", "utf-8") ;
//            String responseMessage = restTemplate.getForObject(url, String.class);
//            JSONObject data = JSONObject.parseObject(responseMessage);
//            JSONObject shortData = data.getJSONObject("data");
//            String shortid = shortData.getString("ae_url");
//        }catch (Exception e){
//            e.printStackTrace();
//        }

//        try {
//            RestTemplate restTemplate = new RestTemplate();
//            String url = "https://www.06q.net/api/?key=n3zsqZIIoXSW&format=json&url=http://118.31.121.214/pay/alipay?orderId=dfsgsfdgsdgsdf";
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
////            headers.set(HttpHeaders.ACCEPT,"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
//            HttpEntity entity = new HttpEntity(headers);
//            String body = restTemplate.exchange(url, HttpMethod.GET, entity, String.class).getBody();
//            // {"code":0,"msg":"","source":"http:\/\/118.31.121.214\/","short_url":"http:\/\/h5ip.cn\/GgSn"}
//            JSONObject result = JSONObject.parseObject(body);
//            if (result.getInteger("error") == 0) {
//                String s= result.getString("short").replace("\\/", "/");
//                System.out.println(s);
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

//        String urlNameString = "https://api.weixin.qq.com/sns/userinfo?access_token=TOKEN&openid=OPENID";

//        String result="";
//        try {
//            // 根据地址获取请求
//            String url = "http://h5ip.cn/index/api?format=json&url=http://gapilan.cn/";
//            HttpGet request = new HttpGet(url);//这里发送get请求
//            // 获取当前客户端对象
//            HttpClient httpClient = new DefaultHttpClient();
//            // 通过请求对象获取响应对象
//            HttpResponse response = httpClient.execute(request);
//
//            // 判断网络连接状态码是否正常(0--200都数正常)
//            if (response.getStatusLine().getStatusCode() == 200) {
//                result= EntityUtils.toString(response.getEntity(),"utf-8");
//                System.out.println(result);
//            }
//        } catch (Exception e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }


//        StringBuilder stringBuilder = new StringBuilder();
//        stringBuilder.append("version=1.0");
//        stringBuilder.append("&customerid=12436");
//        stringBuilder.append("&total_fee=100.00");
//        stringBuilder.append("&sdorderno=207218545458981");
//        stringBuilder.append("&notifyurl=http://47.110.231.165/pay/order/patch");
//        stringBuilder.append("&returnurl=http://47.110.231.165");
//        stringBuilder.append("&f3a277f697a34a75cebd9a9b9552c0e6e005f6d8");
//        String sign = "";
//        try {
//            sign =getMD5(stringBuilder.toString());
//            System.out.println("sign:"+sign);
//        } catch (Exception e) {
//        }
//
//        try {
//            RestTemplate restTemplate = new RestTemplate();
//            stringBuilder = new StringBuilder();
//            stringBuilder.append("version=1.0");
//            stringBuilder.append("&customerid=12436");
//            stringBuilder.append("&sdorderno=207218545458981");
//            stringBuilder.append("&total_fee=100.00");
//            stringBuilder.append("&paytype=alipay");
//            stringBuilder.append("&bankcode=");
//            stringBuilder.append("&notifyurl=http://47.110.231.165/pay/order/patch");
//            stringBuilder.append("&returnurl=http://47.110.231.165");
//            stringBuilder.append("&remark=");
//            stringBuilder.append("&get_code=1");
//            stringBuilder.append("&sign=").append(sign);
//            System.out.println( stringBuilder.toString());
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            HttpEntity entity = new HttpEntity(stringBuilder.toString(), headers);
//            String body = restTemplate.exchange("http://47.107.234.240/apisubmit", HttpMethod.POST, entity, String.class).getBody();
//            System.out.println( body);
//        } catch (Exception e) {
//          e.printStackTrace();
//        }
//        String signTemp = "customerid=12436&status=1&sdpayno=20190703223719859286&sdorderno=20190703223719859286&total_fee=2.00&paytype=alipay&f3a277f697a34a75cebd9a9b9552c0e6e005f6d8";
//        try {
//            String sign = getMD5(signTemp);
//            signTemp = signTemp +"&sign="+sign;
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            HttpEntity entity = new HttpEntity(signTemp, headers);
//            RestTemplate restTemplate = new RestTemplate();
//            String body = restTemplate.exchange("http://localhost/callback/sh", HttpMethod.POST, entity, String.class).getBody();
//            System.out.println( body);
//        } catch (Exception e) {
//           e.printStackTrace();
//        }


//        StringBuilder stringBuilder = new StringBuilder();
//        stringBuilder.append("customerid=12381");
//        stringBuilder.append("&status=").append("1");
//        stringBuilder.append("&sdpayno=201906221475736636");
//        stringBuilder.append("&sdorderno=201906221475736636");
//        stringBuilder.append("&total_fee=100.00");
//        stringBuilder.append("&paytype=alipay");
//        stringBuilder.append("&56ba1f059b9b8357b170e517cc18e110ce95cb79");
//        String sign = "";
//        try {
//            sign =getMD5(stringBuilder.toString());
//            System.out.println("sign:"+sign);
//        } catch (Exception e) {
//        }
//        try {
//            RestTemplate restTemplate = new RestTemplate();
//            stringBuilder = new StringBuilder();
//            stringBuilder.append("status=").append("1");
//            stringBuilder.append("&customerid=12381");
//            stringBuilder.append("&sdpayno=201906221475736636");
//            stringBuilder.append("&sdorderno=201906221475736636");
//            stringBuilder.append("&total_fee=100.00");
//            stringBuilder.append("&paytype=alipay");
//            stringBuilder.append("&remark=");
//            stringBuilder.append("&sign=").append(sign);
//            System.out.println("stringBuilder:"+stringBuilder.toString());
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            HttpEntity entity = new HttpEntity(stringBuilder.toString(), headers);
//            String body = restTemplate.exchange("http://pay.wmgjpay.com/pay/pay_response.php", HttpMethod.POST, entity, String.class).getBody();
//            System.out.println("body:"+body);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }

//        String stringSignTemp="pay_amount=100&pay_applydate=2019-06-27 14:11:51&pay_bankcode=904&pay_callbackurl=http://www.shangjindai.cn/Pay_Charges_callback.html&pay_memberid=10222&pay_notifyurl=http://www.shangjindai.cn/Pay_Charges_notify.html&pay_orderid=C20190627141151731886&key=n6idssqna2pi7eczzu4we6pfn8yf2xgk";
//        String sign = "";
//        try {
//            sign = getMD5(stringSignTemp);
//            System.out.println("sign:"+sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        StringBuilder stringBuilder = new StringBuilder();
//        stringBuilder.append("pay_memberid=").append("10222");
//        stringBuilder.append("&pay_orderid=").append("C20190627141151731886");
//        stringBuilder.append("&pay_applydate=").append("2019-06-27 14:11:51");
//        stringBuilder.append("&pay_bankcode=904");
//        stringBuilder.append("&pay_notifyurl=").append("http://192.168.0.102/callback/pdd");
//        stringBuilder.append("&pay_callbackurl=").append("http://192.168.0.102/callback/pdd");
//        stringBuilder.append("&pay_amount=").append("100");
//        stringBuilder.append("&pay_md5sign=").append(sign);
//        stringBuilder.append("&pay_productname=收款");
//        stringBuilder.append("&pay_productnum=");
//        stringBuilder.append("&pay_productdesc=");
//        stringBuilder.append("&pay_producturl=");
//        System.out.println("setToPDDNextOrder:"+stringBuilder.toString());
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//        HttpEntity entity = new HttpEntity(stringBuilder.toString(), headers);
//        String body = restTemplate.exchange("http://www.shangjindai.cn/Pay_Index.html", HttpMethod.POST, entity, String.class).getBody();
//        System.out.println("body:"+body);


//        String signTemp = "amount=100&datetime=2019-06-27 14:11:51&memberid=10222&orderid=20190628091816915960&returncode=00&transaction_id=20190628091816915960&key=n6idssqna2pi7eczzu4we6pfn8yf2xgk";
//        System.out.println(signTemp);
//        String sign = "";
//        try {
//            sign = getMD5(signTemp).toUpperCase();
//            System.out.println("sign:" + sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        StringBuilder stringBuilder = new StringBuilder();
//        stringBuilder.append("memberid=").append("10222");
//        stringBuilder.append("&orderid=").append("20190628091816915960");
//        stringBuilder.append("&amount=").append("100");
//        stringBuilder.append("&transaction_id=").append("20190628091816915960");
//        stringBuilder.append("&datetime=2019-06-27 14:11:51");
//        stringBuilder.append("&returncode=00");
//        stringBuilder.append("&sign=").append(sign);
//        System.out.println("setToPDDNextOrder:" + stringBuilder.toString());
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//        HttpEntity entity = new HttpEntity(stringBuilder.toString(), headers);
//        String body = restTemplate.exchange("http://192.168.8.167/callback/pdd", HttpMethod.POST, entity, String.class).getBody();
//        System.out.println("body:" + body);


//        String callbackUrl ="http://127.0.0.1/callback/jh";
//        String stringSignTemp = "appid=584664&code=6&money=100.00&nonce_str="
//                + System.currentTimeMillis() + "&noticeurl=" + callbackUrl +
//                "&orderid=20190704091816915961&service=pay&time=" + System.currentTimeMillis() + "&version=2.1";
//        String sign = "";
//        try {
//            System.out.println("setToJHNextOrder:" + stringSignTemp + "&key=519e89dae55f15072e8e915219504147");
//            sign = Md5Utils.androidMD5(stringSignTemp + "&key=519e89dae55f15072e8e915219504147");
//            System.out.println("setToJHNextOrder加密结果:" + sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        stringSignTemp = stringSignTemp + "&sign=" + sign;
//        System.out.println("setToPDDNextOrder" + stringSignTemp);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//        HttpEntity entity = new HttpEntity(stringSignTemp, headers);
//        String body = restTemplate.exchange("http://www.dnzke.com/pay/gateway/", HttpMethod.POST, entity, String.class).getBody();
//        System.out.println("setToJHNextOrder result:" + body);
//        JSONObject object = JSONObject.parseObject(body);
//        int code = object.getIntValue("code");
//        if (code != 0) {
//            System.out.println("code code:" + code);
//        }
//        JSONObject data = object.getJSONObject("data");
//        String _payUrl = data.getString("payurl");
//        JSONObject result = new JSONObject();
//        JSONObject payData = new JSONObject();
//        payData.put("payUrl", _payUrl);
//        result.put("data", payData);
//        System.out.println(result.toJSONString());


//        String callbackUrl ="http://127.0.0.1/callback/jh";
//        String stringSignTemp = "10002019071100220203alipay" + callbackUrl
//               + callbackUrl + "1";
//        String sign = "";
//        try {
//            System.out.println("一次字符串:" + stringSignTemp);
//            sign = Md5Utils.androidMD5(stringSignTemp);
//            System.out.println("一次加密结果:" + sign);
//            System.out.println("二次字符串:" + sign+ "6b2ab880-88fe0853-d3cc94c0-eaa8b639");
//            sign = Md5Utils.androidMD5( sign + "6b2ab880-88fe0853-d3cc94c0-eaa8b639");
//            System.out.println("二次加密结果:" + sign);
//        } catch (Exception e) {
//        }
//
//        stringSignTemp = "price=1000&out_order_id=2019071100220203&type=alipay&notifyurl=" + callbackUrl
//                + "&returnurl=" + callbackUrl + "&extend=1" + "&app_id=2614485498" + "&sign=" + sign;
//        RestTemplate restTemplate = new RestTemplate();
//        System.out.println("请求参数:" + stringSignTemp);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//        HttpEntity entity = new HttpEntity(headers);
//        JSONObject body = restTemplate.exchange("http://tb.metems.me/addons/pay/api/create.html?"+stringSignTemp, HttpMethod.GET, entity, JSONObject.class).getBody();
//        System.out.println("setToJHNextOrder result:" + body);


//        JSONObject object = JSONObject.parseObject(body);
//        int code = object.getIntValue("code");
//        if (code != 0) {
//            System.out.println("code code:" + code);
//        }
//        JSONObject data = object.getJSONObject("data");
//        String _payUrl = data.getString("payurl");
//        JSONObject result = new JSONObject();
//        JSONObject payData = new JSONObject();
//        payData.put("payUrl", _payUrl);
//        result.put("data", payData);
//        System.out.println(result.toJSONString());


//        String stringSignTemp = "e4fa70c571a3fd284c3e5f5b9750da4d1220201907132058002120.1";
////        String sign = "";
////        try {
////            sign = getSHA256(stringSignTemp);
////        } catch (Exception e) {
////        }

//        stringSignTemp = "mchId=1220&order=20190713205800212&amount=0.1&notifyUrl=www.baidu.com&successUrl=www.baidu.com&errorUrl=www.baidu.com&sign=" + sign;
//        RestTemplate restTemplate = new RestTemplate();
//        System.out.println("请求参数:" + stringSignTemp);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//        HttpEntity entity = new HttpEntity(headers);
//        String body = restTemplate.exchange("http://47.75.41.81/payapi/api/order/createOrder?" + stringSignTemp, HttpMethod.GET, entity, String.class).getBody();
//        System.out.println("setToJHNextOrder result:" + body);
//        String signTemp = "institutionID=213800&orderSN=20190727211322700928&partnerID=786777&payMode=2&payMoney=1000&payObjet=1&payType=9&refreshForResult=http://127.0.0.1/test";


//        String callbackUrl ="http://127.0.0.1/callback/jh";
//        String signStr = "callbackUrl=http://127.0.0.1:8080/callback&customerRequestedIp=211.97.130.72&merchantNumber=10066&merchantOrderNumber=20190920220522&paymentMethod=2&paymentPlatform=2&requestedAmount=500";
//        String sign = "";
//        try {
//            System.out.println("setToJHNextOrder:" + signStr + "&merchantKey=1234567890");
//            sign = Md5Utils.androidMD5(signStr + "&key=B5D7273EA53A1C3499F52B8AA549D828").toUpperCase();
//            System.out.println("setToJHNextOrder加密结果:" + sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        signStr = signStr + "&sign=" + sign;
//        System.out.println("setToPDDNextOrder:" + signStr);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("callbackUrl","http://127.0.0.1:8080/callback");
//        jsonObject.put("customerRequestedIp","211.97.130.72");
//        jsonObject.put("merchantNumber","10066");
//        jsonObject.put("merchantOrderNumber","20190920220522");
//        jsonObject.put("paymentMethod","2");
//        jsonObject.put("paymentPlatform","2");
//        jsonObject.put("requestedAmount","500");
//        jsonObject.put("sign",sign);
//        HttpEntity entity = new HttpEntity(jsonObject.toJSONString(), headers);
//        String body = restTemplate.exchange("https://merchantgatewayapi.group-pay.biz/api/deposit", HttpMethod.POST, entity, String.class).getBody();

//        String body =  HttpUtils.sendSSLPost("https://merchantgatewayapi.group-pay.biz/api/deposit",jsonObject.toJSONString(),"application/json; charset=utf-8");

        // 跳过SSL 验证
//        try{
//            SSLView.trustAllHttpsCertificates();
//        }catch (Exception error){
//
//        }
//
//        HttpsURLConnection.setDefaultHostnameVerifier(new SSLView().hv);
//        String body = RQPayUtils.sendPost("https://merchantgatewayapi.group-pay.biz/api/deposit", jsonObject.toJSONString());
//        System.out.println("setToJHNextOrder result:" + body);

//
//        String signStr = "businessId=14&childOrderno=2019830944957814&time=20191002193211";
//        String sign = "";
//        try {
//            sign = Md5Utils.androidMD5(signStr + "&akdkdkfkdkfdfdfloiuui");
//            System.out.println("setToJHNextOrder加密结果:" + sign);
////            String body =  HttpUtils.sendPost("http://127.0.0.1/pay/list/form",signStr+"&sign="+sign);
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            HttpEntity entity = new HttpEntity(signStr+"&sign="+sign, headers);
//            RestTemplate restTemplate = new RestTemplate();
////            String body = restTemplate.exchange("http://127.0.0.1/pay/list/form", HttpMethod.POST, entity, String.class).getBody();
//            String body = restTemplate.exchange("http://127.0.0.1/pay/singleOrder/form", HttpMethod.POST, entity, String.class).getBody();
//            System.out.println("body:" + body);
//        } catch (Exception e) {
//        }

//        String signStr = "businessId=14&payType=100&childOrderno=eNXGpL2hLYHZrBWtIG9M5&amount=500.00&time=20194704044732";
//        String sign = "";
//        try {
//            sign = Md5Utils.androidMD5(signStr + "&akdkdkfkdkfdfdfloiuui");
//            System.out.println("setToJHNextOrder加密结果:" + sign);
//            HttpHeaders headers = new HttpHeaders();
//            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//            HttpEntity entity = new HttpEntity(signStr+"&sign="+sign+"&returnUrl=http://htzhifu.net/callback/pkTBCallBack&serverUrl=http://www.example.com", headers);
//            RestTemplate restTemplate = new RestTemplate();
//            String body = restTemplate.exchange("http://127.0.0.1/pay/order/formView", HttpMethod.POST, entity, String.class).getBody();
//            System.out.println("body:" + body);
//        } catch (Exception e) {
//        }
//        String param = "childOrderno=191019204213000001&payAmount=1.00&orderStatus=1&time=20191019224421&businessId=140&sign=b37ef46ae572d8585e67fb308f217f64";
//        String body =  HttpUtils.sendSSLPost("https://wwwpreapi.bwit.cc/cn/cgi/api/notice_url_ajax/shunhengpay/126",param,"application/x-www-form-urlencoded; charset=utf-8");
//        System.out.println("body:" + body);


//        String callbackUrl ="http://127.0.0.1/callback/zyq";
//        HashMap<String,String> hashMap = new HashMap<>();
//        hashMap.put("merId","20191042");
//        hashMap.put("orderId","20191026185810");
//        hashMap.put("orderAmt","100.00");
//        hashMap.put("channel","zfbh5");
//        hashMap.put("desc","test");
//        hashMap.put("ip","127.0.0.1");
//        hashMap.put("notifyUrl",callbackUrl);
//        hashMap.put("returnUrl",callbackUrl);
//        hashMap.put("nonceStr","aaaaaaa");
//        String stringSignTemp = Util.sortKey(hashMap);
//        String  stringSignTemp ="attch=ALIH5&channel=zfbh5&desc=ceshi&ip=192.168.0.0&merId=20191042&nonceStr=1572163169120099696&notifyUrl=http://www.baidu.com&orderAmt=10.00&orderId=1572163169120099696&returnUrl=http://www.baidu.com";
//        String sign = "";
//        try {
//            System.out.println("setToJHNextOrder:" + stringSignTemp + "&key=BtScmUjvgbwuCRTELZGkdzAIJMqyFHnP");
//            String md5Sign = Md5Utils.androidMD5(stringSignTemp + "&key=BtScmUjvgbwuCRTELZGkdzAIJMqyFHnP").toUpperCase();
//            System.out.println("setToJHNextOrder MD5加密结果:" + md5Sign);
//            // 再进行
//            String privateKey = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDFkNwtbDQsf5C0pOadqDrYgO9lKJrmQihBS4cPn/zh9EylEbrvXjoHijrG+t8DNl0rI79+O1TqA477Z8DbHobZecBGm1AtKjp15GvH5tZ7Dq87FQ/JJiEmyKnlqAYxMZxnYrml/X17eMFCP1SKTW9NmMPOGgptWP1+zSM/pdmV2fh56n2HvgWo32bQPqPA/w/fCbuDP/eZ3gWyDyMEi8xfDY1rEUIianJN//NuLudFI2VlJnAhE8/+1Moq9maRWzvrMZdoAqFIL726AZBtUAiB1yGlaTzsuxsCYwC6ToqzE2stFOpbDj+Q6oli92Mw2RLiGbW7PdNr6zvKuO148vxRAgMBAAECggEAPHN/u3JRYJBD4dJXMkRohRimp6hOBUiW8qu+jtxgT28mCJgtP9LwJKB6LapTlLMMvQd6L5DOAbDHDkwH6cQkdOTZHYGmfbtfGfWjuQ378Llkisp+AwlkuW5K9hd8lY7dkZDWx2CSBbbEQ5YHMy5QcUjeGPFE4YKKRkNUlsQTmNMIjVRYoKVzs91mw6m1VE2IpHLZOdXmvYpZGL0GFZ4dWbO9JtzXqNYXhkRU6adcGZgZLfvV6EauIH5oduKIrb+HETWtEwjOAwW4q80M3oz2uBdqoOJzMqgkcoVAub4+LlkEilYUbd3hD9DPrpj7o6Wkpo5zoA3aFoJku3grYpZoxQKBgQDohwldowA3cN6zGIQiV7tnraKB21fMp4OCikCe63quz/kf5JUCLL9IgpqUhqqp0HLEtgy2IDtdNXpGPbWwLMnJxfXB+1S35a7yX1BSVYarqSIiHpsXAkmjiBdFe4cepQBJJsjqrUaLtcKAOlevraoE3Y7Q8JDvrT7cI6tNoKl3CwKBgQDZgljO11lEewLTcNhAM5JPYQPH6dEn4I5v3V2Z+9Rs7bOV5aT64tDvCj7kJSKomlW5AKNIj8snVhS8ac/0V+1QR7fqz8JWQcLjg5K8US92i0qOsgFGi3VluWpkgw2I7K0Hz6ZVzNLPXv6Gz5WGCAMfYI9O+Wf9IdJwdF9ujsuDkwKBgQCzz5Cvhxfox3B/QCsVv5AdCYmML4kCqlso/C4idmglfI/iWMndp6q3sL9GsaiRrq7BbSIBSIV/e5Y1cQzp0oisblewDOGjX4rcxFYBhT+hySWrCs3ViiBVxCxyv6ZqTSAecU6XIy1VZlWlAPjD0mCSaJ5C9nSt0uO0KiUS33WMpwKBgFiHFwJI4AphTsskWL/4vYoVYGaTog9q9E5PePNdbh5PuRI/f6ClhIhmUSamfq7E8jL0MYEtFXCTNqlhH8TBrNNJ/W9S1DQrW9kiCi0flgPXuabOiHpf9I5MoyL5vB6Ixfwx5e9yCDNi5JGWF7OPu0WgFXP9SvfaNj6S/uyOrgKFAoGBALY0ZbUhgAkstV/4CkjmOx9UNOKof9GcEsDwJavF2tph3tipOTwSsxqFrHzJpOH/860Uz9AzdUoRLmjmOIUTSJZ6CEoir3/78r7MTei3Qn7zCNsbl1RJBW3FfL/I0LoYPNVLDybjZPEBAUhZ1bOyT04hhFfSZCBSIMPd5xCMr4UR";
//            sign = SHA256WithRSAUtils.buildRSASignByPrivateKey(md5Sign, privateKey);
//            System.out.println("rsa 加密结果:" + sign);
////            boolean b = SHA256WithRSAUtils.buildRSAverifyByPublicKey(md5Sign, publicKey,sign);
////            System.out.println("rsa 解密结果:" + b);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        stringSignTemp = stringSignTemp + "&sign=" + sign;
//        System.out.println("setToPDDNextOrder:" + stringSignTemp);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//        HttpEntity entity = new HttpEntity(stringSignTemp, headers);
////        String body = HttpUtils.sendPost2("http://api.p5ckq.cn/pay",stringSignTemp);
//        String body = restTemplate.exchange("http://api.p5ckq.cn/pay", HttpMethod.POST, entity, String.class).getBody();
//        System.out.println("setToJHNextOrder result:" + body);


        //     String callbackUrl ="http://127.0.0.1/callback/jh";


//        String signStr = "BuCode=abc123345556&OrderId=201910280023&PayChannel=WeChat&OrderAccount=Guest001&Amount=1000";
//        String sign = "";
//        try {
//            System.out.println("setToJHNextOrder:" + signStr + "&key=623c935a6fe112fd7011c1da3931f262");
//            sign = Md5Utils.androidMD5(signStr + "&Key=623c935a6fe112fd7011c1da3931f262");
//            System.out.println("setToJHNextOrder加密结果:" + sign);
//        } catch (Exception e) {
//        }
//        RestTemplate restTemplate = new RestTemplate();
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//
//        Map<String, String> map = new HashMap<>();
//        String reqTime = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
//        String orderNo = reqTime + new DecimalFormat("00000").format(new Random().nextInt(99999));
//        map.put("merchNo", "526487");
//        map.put("orderNo", orderNo);
//        map.put("amount", new DecimalFormat("0.00").format(100));
//        map.put("currency", "CNY");
//        map.put("outChannel", "ALIPAY_QRCODE");
//        map.put("returnUrl", "http://www.baidu.com");
//        map.put("notifyUrl", "http://www.baidu.com");
//        map.put("reqTime", reqTime);
//        map.put("attach", "ttttt");
//        map.put("userId", String.valueOf(new Random().nextInt(100000000)));
//        String key ="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCcz1yFoRakxHD2kGUv05ZBHXKFiw1Jz0RnwEM5cJLTPk0OeJ/fe90capGnID8Tl+Iol3CdDz0l9vR0FCoqSX5S5yvcjLmEMjs5vSjudGfoXRJmKBv+ZNiTqNSm4vLUjI+2u9s2Ccz5YZlHBm9tf55v+2hVfKrFCIWp5KbU9FFcjQIDAQAB";
//        String jsonObj = JSONObject.toJSONString(map);
//        String sign = Md5Utils.androidMD5(jsonObj+key);
//        String context = Base64.getEncoder().encodeToString(jsonObj.getBytes());
//        JSONObject bodyParam = new JSONObject();
//        bodyParam.put("sign",sign);
//        bodyParam.put("context",context);
//        bodyParam.put("encryptType","MD5");
//        HttpEntity entity = new HttpEntity(bodyParam.toJSONString(), headers);
//        String body = restTemplate.exchange("http://129.211.163.161:9999/pay/order", HttpMethod.POST, entity, String.class).getBody();
//        System.out.println("body:" + body);
        //  Base64.getDecoder().decode(body)

//                RestTemplate restTemplate = new RestTemplate();
//        stringSignTemp = stringSignTemp + "&sign=" + sign;
//        System.out.println("setToPDDNextOrder:" + stringSignTemp);
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//        HttpEntity entity = new HttpEntity(stringSignTemp, headers);

//        String str = "amount=1&dcMethod=5&merCode=0229171645613275&notifyUrl=http://www.baidu.com&orderNo=o1574142057422&subject=test";
//        String sign = Md5Utils.androidMD5(str+"key=Q4zygV9V4BcrC5EE");
//        String result = HttpUtils.sendPost2("http://api.pifukuilan.com/pay/pay",str+"&sign="+sign);
//        System.out.println("setToPDDNextOrder:" + result);
//        String str = "currencyCode=156&merNo=TEST2000001&merOrderId=0229171645613275&orderDesc=test&txnAmt=100&txnTime=202004102257";
//        String sign = Md5Utils.getSHA256(str+"&key2000001");
//        String result = HttpUtils.sendPost2("http://52.81.173.88:9001/online/gway/frontConsume",str+"&signature="+sign);
//        System.out.println("setToPDDNextOrder:" + result);

        String reqTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());

        System.out.println(TimeZone.getDefault().getID());
    }
}
